#include <iostream>
#include <string>
#include <memory>

using namespace std;

/*
\ brief:  首页视图
\ author: 清晨与猫鱼
*/
class HomeView {
public:
    void show() {
        cout << "Displaying Home Page" << endl;
    }
};

/*
\ brief:   学生视图
\ author: 清晨与猫鱼
*/
class StudentView {
public:
    void show(){
        cout << "Displaying Student Page" << endl;
    }
};


/*
\ brief:   调度员
\ author: 清晨与猫鱼
*/
class Dispatcher {
public:

    void dispatch(string request) {
        if (request == "STUDENT") {
            studentView_.show();
        }else {
            homeView_.show();
        }
    }

private:
    StudentView studentView_;
    HomeView homeView_;
};


/*
\ brief:   前端控制器
\ author: 清晨与猫鱼
*/
class FrontController {
public:
    void dispatchRequest(string request) {
        trackRequest(request);

        if (isAuthenticUser()) {
            dispatcher_.dispatch(move(request));
        }

    }

private:
    bool isAuthenticUser() {
        cout << "User is authenticated successfully." << endl;
        return true;
    }

    void trackRequest(string request) {
        cout << "Page requested: " << request << endl;
    }
private:
    Dispatcher dispatcher_;
};